import React from "react";
import {DataSourceType} from "../pages/DataSource";
import {SqlStatementType} from "../pages/SqlPage";
import type {MessageInstance} from "antd/es/message/interface";
type AppContextProps = {
    dataSources: DataSourceType[];
    setDataSources:  React.Dispatch<React.SetStateAction<DataSourceType[]>>;
    sqlStatements: SqlStatementType[];
    setSqlStatements: React.Dispatch<React.SetStateAction<SqlStatementType[]>>;
    messageApi: MessageInstance;
}

export const AppContext = React.createContext<AppContextProps | undefined>(undefined);

export const useAppContext = (): AppContextProps => {
    const appContextProps = React.useContext(AppContext);
    if (appContextProps === undefined) {
        throw new Error('');
    }
    return appContextProps;
}